#include <iostream>

using namespace std;

int main()
{
    double power(double n,int x);
    int value = 0,i;
    for (i=7;i>=0;i--){
        char ch;
        cin >> ch;
        if (ch == '1')//字符
            value +=static_cast<int>(power(2,i));//数据类型统一
    }
    cout << value << endl;
    return 0;
}

double power(double n,int x)
{
    int val = 1;
    while (x--)
        val*=n;//底数重复相乘
    return val;
}
